package com.example.carmqtt.controller;

import com.example.carmqtt.service.VehicleMqttService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

/**
 * @author Weizheng Liu
 * @date 2025/4/16 10:47
 * @description
 */
@RestController
@RequestMapping("/api/vehicles")
public class VehicleController {

    @Autowired
    private VehicleMqttService mqttService;

    // 发送指令给指定小车
    @PostMapping("/{id}/command")
    public ResponseEntity<String> sendCommand(
            @PathVariable String id,
            @RequestBody String command) {
        mqttService.sendCommand(id, command);
        return ResponseEntity.ok("指令已发送");
    }
}